package Apresentation;


import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;

import Domain.Account;
import Domain.Catalog;
import Domain.Contact_information;
import Domain.Customer;
import Exception.DadosException;
import Integration.Integration;
import Integration.IntegrationImpl;

@ManagedBean
@ViewScoped
public class NovoCatalogo {
	
	
	private Catalog catalogo;
	
	public Catalog getCatalogo() {
		return catalogo;
	}

	public void setCatalogo(Catalog catalogo) {
		this.catalogo = catalogo;
	}

	public NovoCatalogo() {
		super();
		catalogo = new Catalog();
		
	}
	
	public String novaCatalogo(){
		
		Integration it = new IntegrationImpl();		
		
		
		try {
			it.salvarCatalogo(catalogo);
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Catalogo Salvo com sucesso",""));
			catalogo.setName("");
			return null; 
		} catch (DadosException e) {			
			e.printStackTrace();
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,e.getMessage(),""));  
			System.out.println(e.getMessage());
			}
		
		return null;
	}
	
	
	
	
	
	

}
